package com.ruoyi.cms.controller;

import com.ruoyi.cms.service.CIndexService;
import com.ruoyi.cms.utils.FileUtils;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

/**
 * @Author Choi
 * @Date 2021/10/15
 */

@RestController
@RequestMapping("/cms/config")
public class CConfigController {

    @Autowired
    private CIndexService indexService;

    /**
     * 清理缓存
     */
    @GetMapping("/clear")
    public AjaxResult clear() {
        indexService.clearConfig();
        try {
            String file = RuoYiConfig.getProfile() + "/upload";
            String str = FileUtils.zipFile(new File(file), "zip");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }
}
